<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改安全摘要')"/>
    <th:block th:include="include :: tinymce"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-content-edit" th:object="${cmsContent}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">标题：</label>
            <div class="col-sm-8">
                <textarea name="title" class="form-control" placeholder="摘要标题">[[*{title}]]</textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">内容：</label>
            <div class="col-sm-8">
                <textarea class="summernote" id="content" name="content" th:field="*{content}"></textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">排序：</label>
            <div class="col-sm-8">
                <input name="idx" th:field="*{idx}" class="form-control" type="text">
            </div>
        </div>

        <div class="box-footer">
            <div class="col-sm-offset-5 col-sm-6">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i
                        class="fa fa-check"></i>保 存
                </button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i
                        class="fa fa-reply-all"></i>关 闭
                </button>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "news/content";
    var imgUrl = [[${cmsContent.thumb}]]
    var initialPreview = []

    if (imgUrl) {
        initialPreview = [base + imgUrl]
    }

    $("#form-content-edit").validate({
        rules: {
            title: "required",
            idx: "required"
        },
        messages: {
            title: "必填项",
            idx: "必填项"
        }
    });


    function submitHandler() {
        $('#content').val(tinyMCE.get('content').getContent())
        if ($.validate.form()) {
            $.operate.saveTab(prefix + "/edit", $('#form-content-edit').serialize());
        }
    }


    initTinyMec('#content')
</script>
</body>
</html>